let arr=[30,55,{name:function(){}}];
let obj={name:'kk',age:18};
let num=1;
function copy(target){
    let temp;
    if(target instanceof Object){
        if(target instanceof Array){
            temp=[];
        }else {
            temp=[];
        }
        for(key in target){
            if(target[key] instanceof Object){
                temp[key]=copy(target[key]);
            }else {
                temp[key]=target[key];
            }
        }
    }else {
        temp=target;
    }
    return temp;
}

console.log(copy(num));
console.log(copy(arr));
console.log(copy(obj));